/***************************************************************
Made by: Cultured::Labs

Copyright 2010 Cultured::Labs
****************************************************************/
#include<cstdlib>
#include<ctime>

#include "random.h"

//Generates a random number
int GenerateNumber() {
  srand(rand() ^ static_cast<unsigned>(time(NULL)));
  int random_number;

  random_number = rand();

  return random_number;
}

//Generates a random number from 1 to max
int GenerateNumber(int max) {
  srand(rand() ^ static_cast<unsigned>(time(NULL)));
  int random_number; 
  int lowest = 1, highest = max; 
  int range = (highest-lowest) + 1; 

  random_number = lowest + int(range * rand() / (RAND_MAX + 1.0)); 

  return random_number;
}

//Generates a random number from min to max
int GenerateNumber(int min, int max) {
  srand(rand() ^ static_cast<unsigned>(time(NULL)));
  int random_number; 
  int lowest = min, highest = max; 
  int range = (highest-lowest) + 1; 

  random_number = lowest + int(range * rand() / (RAND_MAX + min)); 

  return random_number;
}